fix(core): report process exit before stdio close#29476
Closed
YOMXXX wants to merge 1 commit into
Closed
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: I found a highly related PR: PR #29108: fix(core): resolve spawn on exit not close to avoid bg-child hang This PR appears to be addressing the same underlying issue - preventing background child process hangs by completing on the The other results (PRs #29378, #29340) are related to stdio flushing/draining but address different contexts (export/CLI exit) rather than the core spawn behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #29294
Type of change
What does this PR do?
The cross-spawn process handle used
closeto completeexitCode/isRunning/kill. If a command exited while a detached descendant still held the stdout pipe open,closecould be delayed indefinitely and the shell tool stayedrunning.This changes the process signal to complete on the child
exitevent, withcloseonly kept as a fallback if it fires first. The shell tool now waits for its output reader to drain after exit, but only for a short bounded window, so normal output is preserved while inherited pipes can no longer wedge the tool forever.How did you verify your code works?
TDD check:
PATH="$HOME/.bun/bin:$PATH" bun test test/effect/cross-spawn-spawner.test.ts -t "returns exit code before inherited stdout pipe closes"failed by timing out after 5000ms.From
packages/core:PATH="$HOME/.bun/bin:$PATH" bun test test/effect/cross-spawn-spawner.test.ts- 25 pass, 0 failPATH="$HOME/.bun/bin:$PATH" bun typecheck- passedFrom
packages/opencode:PATH="$HOME/.bun/bin:$PATH" bun test test/tool/shell.test.ts -t "returns when command exits before inherited stdout closes"- passedPATH="$HOME/.bun/bin:$PATH" bun test test/tool/shell.test.ts- 24 pass, 0 failPATH="$HOME/.bun/bin:$PATH" bun typecheck- passedFrom the repo root:
PATH="$HOME/.bun/bin:$PATH" bunx prettier --check packages/core/src/cross-spawn-spawner.ts packages/core/test/effect/cross-spawn-spawner.test.ts packages/opencode/src/tool/shell.ts packages/opencode/test/tool/shell.test.ts- passedgit diff --check- passedPATH="$HOME/.bun/bin:$PATH" .husky/pre-push- failed in unrelated@opencode-ai/console-supporttypecheck because local dependencies/generated files are missing (@solidjs/*,solid-js/jsx-runtime,vite, and generated@opencode-ai/console-core/*schema modules).@opencode-ai/core:typecheckandopencode:typecheckcompleted before that failure.Screenshots / recordings
Not a UI rendering change.
Checklist